<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

use app\api\controller\AppsController;
use app\api\controller\CommonController;
use app\api\controller\UsersController;
use app\api\middleware\CryptMiddleware;
use app\api\middleware\DeviceMiddleware;
use app\api\middleware\TokenAuthMiddleware;

use Webman\Route;

Route::options('[{path:.+}]', function (){
   return response('');
});

Route::group('/api', function () {
   // common
   Route::group('/common', function () {
      Route::get('/test', [CommonController::class, 'test']);
   });
    // users
   Route::group('/users', function () {
      Route::get('/info', [UsersController::class, 'info'])->middleware([TokenAuthMiddleware::class]);
      Route::post('/register', [UsersController::class, 'register']);
      Route::post('/login', [UsersController::class, 'login']);
      Route::get('/loginout', [UsersController::class, 'loginout'])->middleware([TokenAuthMiddleware::class]);
   });
   // apps
   Route::group('/apps', function () {
      Route::get('/list', [AppsController::class, 'list']);
      Route::post('/create', [AppsController::class, 'create']);
      Route::put('/update/{id}', [AppsController::class, 'update']);
      Route::get('/detail/{id}', [AppsController::class, 'detail']);
      Route::get('/statistics/{id}', [AppsController::class, 'statistics']);
   })->middleware([TokenAuthMiddleware::class]);
   // apps
   Route::group('/device', function () {
         Route::post('/info', [AppsController::class, 'info']);
         Route::post('/custom', [AppsController::class, 'custom']);
         Route::post('/event', [AppsController::class, 'event']);
      })->middleware([DeviceMiddleware::class,CryptMiddleware::class,]);
 });

 Route::disableDefaultRoute();





